package locations.actions;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.interceptor.ServletRequestAware;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import locations.dao.implement.ProblematicTypeDAOHibernateJPA;
import locations.model.TipoProblematica;

public class EditProblematicTypeAction extends ActionSupport implements ModelDriven<TipoProblematica>, ServletRequestAware  {
	
    private static final long serialVersionUID = -8124967730231198191L;

    private HttpServletRequest request; 
    private TipoProblematica problematicType = new TipoProblematica();

    public String execute(){
            Long id = Long.parseLong(this.getRequest().getParameter("id"));
            ProblematicTypeDAOHibernateJPA dao = new ProblematicTypeDAOHibernateJPA();
            this.problematicType = dao.retrieveById(id);
            return SUCCESS;
    }

    public TipoProblematica getProblematicType() {
            return problematicType;
    }

    public void setProblematicType(TipoProblematica problematicType) {
            this.problematicType = problematicType;
    }

    @Override
    public TipoProblematica getModel() {
            return this.problematicType;
    }

    public HttpServletRequest getRequest() {
            return request;
    }

    @Override
    public void setServletRequest(HttpServletRequest request) {
            this.request = request;

    }
}